<template>
  <div class="from">
      <iframe :src="curSrc"></iframe>
      <button v-show="btnIsShow" @click="toTatget" class="from-target"></button>
  </div>
</template>
<script>
export default {
  name: "fromeurl",
  data() {
    return {
        btnIsShow:false,
      // current iframe src
      curSrc: "",
      // target src array
      srcArr: [
        'https://b.leyaoyao.com/customer/redcoins/obtain?redCoinsId=1084591&distributorId=1050166',
        'https://b.leyaoyao.com/customer/redcoins/obtain?redCoinsId=1084592&distributorId=1050166',
        'https://b.leyaoyao.com/customer/redcoins/obtain?redCoinsId=1084609&distributorId=1050166',
        'https://b.leyaoyao.com/customer/redcoins/obtain?redCoinsId=1084610&distributorId=1050166',
        'https://b.leyaoyao.com/customer/redcoins/obtain?redCoinsId=1084612&distributorId=1050166',
        'https://b.leyaoyao.com/customer/redcoins/obtain?redCoinsId=1084613&distributorId=1050166',
        'https://b.leyaoyao.com/customer/redcoins/obtain?redCoinsId=1084614&distributorId=1050166',
        'https://b.leyaoyao.com/customer/redcoins/obtain?redCoinsId=1084615&distributorId=1050166',
        'https://b.leyaoyao.com/customer/redcoins/obtain?redCoinsId=1084616&distributorId=1050166',
        'https://b.leyaoyao.com/customer/redcoins/obtain?redCoinsId=1085822&distributorId=1050166',
        'https://b.leyaoyao.com/customer/redcoins/obtain?redCoinsId=1085823&distributorId=1050166',
        'https://b.leyaoyao.com/customer/redcoins/obtain?redCoinsId=1085824&distributorId=1050166',
        'https://b.leyaoyao.com/customer/redcoins/obtain?redCoinsId=1085825&distributorId=1050166',
        'https://b.leyaoyao.com/customer/redcoins/obtain?redCoinsId=1085826&distributorId=1050166',
        'https://b.leyaoyao.com/customer/redcoins/obtain?redCoinsId=1085827&distributorId=1050166',
        'https://b.leyaoyao.com/customer/redcoins/obtain?redCoinsId=1085828&distributorId=1050166',
        'https://b.leyaoyao.com/customer/redcoins/obtain?redCoinsId=1085829&distributorId=1050166',
        'https://b.leyaoyao.com/customer/redcoins/obtain?redCoinsId=1085830&distributorId=1050166',
        'https://b.leyaoyao.com/customer/redcoins/obtain?redCoinsId=1085831&distributorId=1050166',
        'https://b.leyaoyao.com/customer/redcoins/obtain?redCoinsId=1085832&distributorId=1050166',
      ]
    };
  },
  methods: {
    // click button to next route
    toTatget() {
      this.$router.push("/start");
    }
  },
  created() {
    // modify document title
    document.title = "肯德基娃娃机体验券领取页";

    const count = window.localStorage.getItem("loopFlag");
    this.curSrc = this.srcArr[parseInt(count)];
    // 判断是否是安卓手机
    var u = window.navigator.userAgent;
    var isAndroid = u.includes("Android");
    if (isAndroid) {
      window.location.href = this.curSrc;
    }
  },
  mounted() {
    let timer = null;
    timer = setInterval(() => {
      if (document.readyState == "complete") {
        clearInterval(timer);
        this.btnIsShow = true;
      }
    }, 1000);
  }
};
</script>
<style scoped lang="scss">
.from {
  position: relative;
  width: 100%;
  height: 100%;
  iframe {
    width: 100%;
    height: 100%;
    border: 0;
  }
  &-target {
    position: absolute;
    top: 16.2rem;
    left: 50%;
    transform: translateX(-50%);
    width: 6rem;
    height: 2.04rem;
    background: url("../common/img/anniu.png")no-repeat center/100% 100%;
  }
}
</style>
